﻿using System.Collections;
using System.Collections.Generic;
using System.IO;
using System;
using UnityEditor;
using UnityEngine;

public class BuildTool
{
    private static string OutputName { get => DateTime.Now.ToString("yyyy_MM_dd_HH_mm"); }

    [MenuItem("Custom/AssetBundle/Build")]
    public static void BuildAssetBundle()
    {
        AssetsBundleBuilder.BuildAndCompressAssets();

        BuildPlayerOptions options = new BuildPlayerOptions();

#if UNITY_ANDROID
        options.targetGroup = BuildTargetGroup.Android;
        options.target = BuildTarget.Android;
        options.locationPathName = string.Format("{0}/APK/{1}.apk", PathDefine.PackPath, OutputName);
#elif UNITY_IOS
#error platform ios is not support...
#else
        options.targetGroup = BuildTargetGroup.Standalone;
        options.target = BuildTarget.StandaloneWindows;
        options.locationPathName = string.Format("{0}/{1}/GameEnter.exe", PathDefine.PackPath, OutputName);
#endif
        options.scenes = new string[] { "Assets/Scenes/GameEnter.unity" };
        PlayerSettings.companyName = "suse";
        PlayerSettings.SetApplicationIdentifier(options.targetGroup, "com.suse.yzFramework");
        PlayerSettings.productName = "YZFramewrok";
        PlayerSettings.bundleVersion = "1.0.0";

        BuildPipeline.BuildPlayer(options);

        PlayerSettings.SetScriptingDefineSymbolsForGroup(options.targetGroup, "");
    }
}
